package com.anonymous.community.api.model;

public class LoginResponse {
    private String token;
    private User user;
    private int code;
    private String message;
    private LoginData data;
    private boolean success;
    private String accessToken;
    private String refreshToken;

    public String getToken() {
        return token;
    }

    public void setToken(String token) {
        this.token = token;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public LoginData getData() {
        return data;
    }

    public void setData(LoginData data) {
        this.data = data;
    }

    public boolean isSuccess() {
        return success || (code == 200 || code == 0);
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getAccessToken() {
        return accessToken != null ? accessToken : (token != null ? token : (data != null ? data.getAccessToken() : null));
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public String getRefreshToken() {
        return refreshToken != null ? refreshToken : (data != null ? data.getRefreshToken() : null);
    }

    public void setRefreshToken(String refreshToken) {
        this.refreshToken = refreshToken;
    }

    public static class LoginData {
        private String token;
        private User user;
        private String accessToken;
        private String refreshToken;

        public String getToken() {
            return token;
        }

        public void setToken(String token) {
            this.token = token;
        }

        public User getUser() {
            return user;
        }

        public void setUser(User user) {
            this.user = user;
        }

        public String getAccessToken() {
            return accessToken != null ? accessToken : token;
        }

        public void setAccessToken(String accessToken) {
            this.accessToken = accessToken;
        }

        public String getRefreshToken() {
            return refreshToken;
        }

        public void setRefreshToken(String refreshToken) {
            this.refreshToken = refreshToken;
        }
    }

    public static class User {
        private int id;
        private String username;
        private String anonymous_id;
        private boolean is_verified;
        private String role;

        public int getId() {
            return id;
        }

        public void setId(int id) {
            this.id = id;
        }

        public String getUsername() {
            return username;
        }

        public void setUsername(String username) {
            this.username = username;
        }

        public String getAnonymousId() {
            return anonymous_id;
        }

        public void setAnonymousId(String anonymous_id) {
            this.anonymous_id = anonymous_id;
        }

        public boolean isVerified() {
            return is_verified;
        }

        public void setVerified(boolean is_verified) {
            this.is_verified = is_verified;
        }

        public String getRole() {
            return role;
        }

        public void setRole(String role) {
            this.role = role;
        }
    }
}